import 'package:flutter/material.dart';

void main() {
  runApp(const MaterialApp(
    title: 'Flutter第一天',
    home: MyScaffold(),
  ));
}

//看到const就代表被修饰的这一句话相当于常量,页面刷新时不会对被修饰的控件或者变量进行刷新,节省性能
class MyAppBar extends StatelessWidget {
  const MyAppBar({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 56.0,
      padding: const EdgeInsets.symmetric(horizontal: 8.0),
      decoration: const BoxDecoration(color: Colors.blue),
      child: Row(
        children: const [
          IconButton(onPressed: null, icon: Icon(Icons.menu)),
          Expanded(child: Text("实例标题")),
          IconButton(onPressed: null, icon: Icon(Icons.search))
        ],
      ),
    ); //相当于div
  }
}

class MyScaffold extends StatelessWidget {
  const MyScaffold({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Material(
      child: Column(
        children: const [
          MyAppBar(),
          Expanded(
              child: Center(
            child: Text('你好,世界'),
          ))
        ],
      ),
    );
  }
}
